<template>
  <view class="commonLim-list">
    <view class="searchclass">
      <view class="left">
        <gongxuName :query="query" title="剪线分卷" @fathersFn="handleSearch" />
      </view>
    </view>
    <scroll-view
      class="commonLim-listView"
      scroll-y
      @scrolltolower="onScrollToBottom"
    >
      <view v-show="lists.length">
        <view class="lims_menu_list">
          <view v-for="item in lists" :key="item.id" @click="handleClick(item)">
            <text>{{ `${item.machineName} ${item.counts}条` }}</text>
            <text>{{ item.machineCode }}</text>
          </view>
        </view>
      </view>
      <up-empty mode="data" v-show="lists.length == 0"> </up-empty>
    </scroll-view>
  </view>
</template>

<script setup>
import { searchlist } from "./api.js";
const lists = ref([]);
const query = ref({});
const handleSearch = async () => {
  uni.showLoading({
    title: "加载中",
  });
  try {
    const res = await searchlist(query.value.processBelong);
    if (res.code == 1) {
      lists.value = res.data.content;
    } else {
      lists.value = [];
    }
  } catch (err) {
    lists.value = [];
  } finally {
    uni.hideLoading();
  }
};

const handleClick = (item) => {
  uni.navigateTo({
    url: `/pages/ThreadAndDivideTwo/ThreadAndDivideTwo?machineId=${item.machineId}&machine_code=${item.machineCode}`,
  });
};
onLoad(async () => {});
</script>

<style lang="scss" scoped>
.lims_menu_list {
  padding-top: 24rpx;
  view {
    flex-wrap: nowrap;
  }
}
</style>